<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>拉萨市财政局投资评审管理系统  </title>
    <link rel="stylesheet" href="css/style.css">
    <script src="js/jquery-1.10.2.min.js"></script>
</head>
<body>
<!--main-header start-->
<div class="main-header">
    <div class="w-1200 clearfix">
        <div class="header-logo fl"><a href=""><img src="images/logo.png"></a> </div>
        <!--header-person start-->
        <div id="head_login"></div>
        <script type="text/javascript">
          
          $("#head_login").load("login_common.html");
        </script>
        <!--header-person end-->
        <!--header-nav start-->
        <div class="header-nav fr">
            <ul class="nav">
                <li><a href="/leaaderindex.html">待审核项目</a> </li>
                <li><a href="/leaaderindex2.html">已审核项目</a> </li>
                <span id="art"></span>
                <script>$("#art").load("artcommon.html")</script>
            </ul>
        </div>
        <!--header-nav end-->
    </div>
</div>
<!--main-header end-->
<!--scan-container start-->
<div class="scan-container w-1200" id="maibox">
    <!--scan-step start-->
    <div class="scan-step clearfix">
        <div class="scan-step-hd fl">项目进度</div>
        <div class="scan-step-bd">
            <div class="step-num">
                <span class="circle">1</span>
                <p>资料准备</p>
            </div>
            <div class="step-num">
                <span class="circle">2</span>
                <p>预审中</p>
            </div>
            <div class="step-num">
                <span class="circle">3</span>
                <p>评审中</p>
            </div>
            <div class="step-num">
                <span class="circle">4</span>
                <p>复核中</p>
            </div>
            <div class="step-num">
                <span class="circle">5</span>
                <p>定审中</p>
            </div>
            <div class="step-num">
                <span class="circle">6</span>
                <p>完结</p>
            </div>
        </div>
    </div>
    <!--scan-step end-->
    <!--scan-main start-->
    <div class="scan-main">
        <!--scan-box start-->
        
        <div id="sm"></div>
        <script>$("#sm").load("common-iteminfo.html")</script>
        <!--scan-box end-->
        <!--scan-box start-->
        <div class="scan-box" id="filebox">
            <script>
                $("#filebox").load("filedetail.html");
            </script>
        </div>
        <!--scan-box end-->

    </div>




    <div class="scan-main">
        <!--scan-box start-->
    
        <div id="leader"></div>
        <script>$("#leader").load("assigncommon.html")</script>
        

    </div>




    <div id="reject">
        
           
    </div>


    <!--scan-main end-->
    <!--scan-main start-->





    
    

</div>
<script src="js/auth.js"></script>
<!--scan-container end-->
<script type="text/javascript">
        // $("#approve").hide();
    var id=getQueryString("id");
    console.log(id);
    $.get(HTTP_HOST+"api/Leader/dsdetail?id="+id,function(res){
    
            if (res.code == 200) {
                item = res.result.item;
                filllogs(res.result.logs);
    
                    $("#xmbd").html(item.xmbd);
                    $("#xmlxr").html(item.contactor);
                    $("#address").html(item.address);
                    $("#name").html(item.name);
                    $("#type").html(item.type);
                    $("#owner").html(item.owner);
                    $("#industry").html(item.industry);
                    $("#lxwh").html(item.lxnumber);
                    $("#yjbh").html(item.yjbh);
    
                    $("#wtdw").html(item.wtdw);
                    $("#wtdwlxr").html(item.wtdwcontactor);
                    $("#wtdwlxrdh").html(item.wtdwcontactorphone);
                    $("#cash").html(item.cash);
                
                    var logs = res.result.logs;

                    var log = "";

                    $.each(logs,function(k,v){
                        var orga = "";
                        if(v.isgroup == 1){
                            orga = "专家小组意见";
                        }else{
                            if(v.usertype==4){
                                orga = "专家";
                            }else if(v.usertype == 5){
                                orga = "机构";
                            }else if(v.usertype == 2){
                                orga = "业主复审";
                            }else if(v.usertype == 6){
                                orga = "评审专员";
                            }else if(v.usertype ==3){
                                orga="分管领导";
                            }
                        }
                        log+=`<div class="scan-opinion-hd">
                    <div class="tit">`+orga+`</div>
                    <div class="txt">`+v.idea+`</div>
                </div>`;


                    });
                    $("#logbox").html(log);

                    


                var index = getstat(item.status);
                console.log("inde is.."+index);
            $(".step-num").each(function(k,obj){
                if(k<=index){
                    $(obj).addClass("on");
                }  
            });
                    if(item.status == 6){
                        var action=`<div class="scan-main">
        <!--scan-box start-->
        <div class="scan-box">
            <div class="scan-box-tit">定审意见</div>
            <div class="scan-opinion-text">
                <div class="text-bor">
                    <textarea rows="5" id="idea" placeholder="在此输入你对此次项目的具体评审意见"></textarea>
                </div>
            </div>
        </div>
        <!--scan-box end-->
    </div>
    <!--scan-main end-->



    <!--add-item start-->
        <div class="add-item">
            <div class="con w-full">
                <div class="input-w" style="width:1140px; margin: 0; ">
                    <div class="add-item-flex">
                        <div class="add-item-up">
                            <input type="file" multiple="multiple" class="add-item-up-file"   name="file[]" id="fileapprove" />
                            <span><img src="images/add2.png" ></span>
                        </div>
                        <div class="add-item-tip">
                            <p>1、可上传附件.</p>
                            <p>2、支持压缩包格式：rar、zip。</p>
                            <p>3、支持图片格式：jpeg、jpg、bmp、png。</p>
                            <p>4、支持办公文件格式：doc、docx、xls、xlsx、pdf、ppt。</p>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        <!--add-item end-->
        <!--add-item-files start-->
        <div class="add-item-files" style="width:1100px; margin: 0; "  id="boxfiles">
           
        </div>
        <!--add-item-files end-->

    </div>
    <!--scan-main end-->




    <!--add-bottom start-->
    <div class="add-bottom mar0">
        <button class="login-btn" onclick="passitem(1)">审核通过</button>
        <button class="login-btn bor" onclick="passitem(0)">驳回申请</button>
    </div>`;

    $(".scan-container").append(action);

    // $("#approve").show();
                    }

    
                }
    
    },'JSON');



    function passitem(res){
        var filebox = [];
        $(".fileapp").each(function(){
	var filepath = $(this).attr("value");
	var filename = $(this).attr("name");
    filebox.push({"filename":filename,"filepath":filepath});
   });
   console.log(filebox);
        $.post("/api/Leader/dealitem",{"id":id,"idea":$("#idea").val(),'appres':res,'files':filebox},function(res){
                if(res.result.code == 200){

                    alert("操作已成功");
                    location.reload();
                }else{
                    alert(res.msg);
                }



        },'Json');

    }
    
    
    
    </script>

    <script>



$("#fileapprove").change(function(){
	        //创建FormData对象
	        var data = new FormData();
	        //为FormData对象添加数据
	        $.each($('#fileapprove')[0].files, function(i, file) {
	            data.append('upload_file'+i, file);
	        });

	       console.log(data);

	        //发送数据
        $.ajax({
	            url:HTTP_HOST+'api/Index/upload',
	            type:'POST',
	            data:data,
	            cache: false,
	            contentType: false, //不可缺参数
	            processData: false,     //不可缺参数
	            success:function(data){
	                console.log(data);
			   var res = ""; 
			$.each(data.result,function(k,v){
				res+= `<div class="add-item-files-span">`+k+`：`+v+`<span class="close" onclick="removefile(this)">X</span><input type='hidden' value=`+v+` name=`+k+` class='fileapp'>
            </div>`;	

			});
              console.log(res);
			   $("#boxfiles").append(res);

	            },
	            error:function(){
	                alert('上传出错');
	                $(".loading").hide();   //加载失败移除加载图片
	            }
	        });
	    });



    </script>
</body>
</html>